#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
    struct dirent *dt;
    if (argc != 2)
    {
        fprintf(stderr, "程序错误：运行程序时请带入参数(./29-opendir path)\n");
        exit(-1);
    }
    DIR * dirp = opendir(argv[1]);
    if (dirp == NULL)
    {
        perror("opendir");
        exit(-1);
    }
    while ((dt = readdir(dirp)) != NULL)
    {
        if (strncmp(dt->d_name,".",1) == 0)//strncmp比较函数  比较 “.” ，比较位数 1位
        {
            continue;
        }
        
        printf("%s  ",dt->d_name);
        
    }
    printf("\n");
    closedir(dirp);
    
    return 0;
}
